<?php


namespace app\index\controller;

use think\Controller;
use think\Db;
class PersenIncome extends Controller
{
    public function index(){
        return $this->fetch();
    }

    //基础信息表格数据渲染
    public function getPersenIncome(){
        $page = request()->param('page');
        $limit = request()->param('limit');
        $start = ($page-1) * $limit;
        $modoules = input('name');
        $value =input('job_number');

        $info = Db('person_annual_wage')
            ->join('user', ' person_annual_wage.user_id = user.id ')

            ->where([
                    'person_annual_wage.isdelete'=>0,
                    'user.job_number'=>SESSION('jobNumber')
                ]);



        $IncomeList = $info->limit($start,$limit)->select();
        $count = $info->limit($start,$limit)->count();


        /**  每月发放部分
         * a.岗位工资：对应岗位等级，每级别一标准;
         * b.薪级工资：对应岗位等级及薪级，每级别一标准;
         * c.保留福利补贴：对应岗位等级，每级别一标准;
         * d.岗位奖励绩效工资:对应校内岗位，每级别一标准
         * e.基本业绩奖励：对应校内岗位，每级别一标准
         * f.特殊岗位津贴：个别人享受
         * g.物业补贴：对应校内岗位，每级别一标准
         * h.文明奖：每人数值不同
         * i.独生子女费：每人数值不同
         * j.少数民族补贴：仅回族享受
         * k.卫生费：仅女性享受
         * l.博士补贴：仅博士享受，数值不同
         * m.教授补贴：仅非博士的教授享受
         * n.租房补贴：仅引进博士享受
         * o.车补：仅副厅级以上领导享受
         * p.补工资：临时性补发工资
         *②扣除部分：
         *a.住房公积金：从工资中代扣住房公积金
         *b.医保金：从工资中代扣医保金
         *c.养老保险个人（企业）：从工资中代扣企业养老保险金
         *d.养老保险个人：从工资中代扣事业养老保险金
         *e.职业年金个人：从工资中代扣职业年金
         *f.扣个人所得税：从工资中代扣个人所得税
         *g.扣房租：从工资中代扣租房房租
         *h.扣物业：从工资中代扣物业费
         *i.扣水电；从工资中代扣水电费
         *j.扣工资，临时性扣工资项
         *③单独发放收入
         *a.取暖费：每年11月根据职务职称发放的取暖费
         *b.目标考核奖：年度发放的目标考核奖
         *c.全国文明城市奖：年度发放的全国文明城市奖
         *d.绩效工资：年度发放的绩效工资
         */
        //var_dump($IncomeList[1]);
        $array = array();
        if($IncomeList != null){
            foreach($IncomeList as $value){
                $msg = array(
                    //序号
                    'id' => $value['id'],
                    //用户id
                    'user_id' => $value['user_id'],
                    //用户名字
                    'name' => $value['name'],
                    //工号
                    'job_number' => $value['job_number'],
                    //发放日期
                    'wage_date' => $value['wage_date'],

                    //每月应发部分
                    'income' =>
                        $value['job_salary']+
                        $value['job_level_salary']+
                        $value['retention_benefit_subsidy']+
                        $value['job_reward_performance_salary']+
                        $value['basic_performance_award']+
                        $value['special_post_allowance']+
                        $value['property_subsidy']+
                        $value['civilization_award']+
                        $value['one_child_fee']+
                        $value['ethnic_minorities_subsidy']+
                        $value['public_sanitation_fee']+
                        $value['doctor_subsidy']+
                        $value['professor_subsidy']+
                        $value['rental_subsidy']+
                        $value['car_supplement']+
                        $value['supplementary_salary'],
                    //扣除部分
                    'deduction' =>
                        $value['housing_provident_fund']+
                        $value['medical_insurance_fund']+
                        $value['endowment_insurance_individual_enterprise']+
                        $value['endowment_insurance_individual']+
                        $value['occupational_annuity_individual']+
                        $value['deduction_of_individual_income_tax']+
                        $value['deduction_of_rent']+
                        $value['withholding_property']+
                        $value['deduction_of_hydropower']+
                        $value['deduction_of_wages'],
                    //单独发放收入
                    'separately' =>
                        $value['heating_fee']+
                        $value['target_assessment_award']+
                        $value['national_civilized_city_award']+
                        $value['merit_pay']
                );
                array_push($array,$msg);
            }
        }




        $msg = [
            'code' => 0,
            'msg' => '查询成功',
            'data' => $array,
            'count' => $count
        ];

        echo json_encode($msg);
    }


}